<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>选项卡</title>
	<style type="text/css">
		div{
			width:150px;
			height: 150px;
			background: #ccc;
		}
	</style>
</head>
<body>
<a href="javascript:tabs(1)">军事</a>
<a href="javascript:tabs(2)">经济</a>
<a href="javascript:tabs(3)">体育</a>
<div>第一项：军事新闻</div>
<div style="display: none;">第二项：经济新闻</div>
<div style="display: none;">第三项：体育新闻</div>

<script type="text/javascript">
var odiv = document.getElementsByTagName('div');
function tabs(index) {
	// 先让所有的隐藏
	for (var i = 0; i < odiv.length; i++) {
		odiv[i].style.display = 'none';
		odiv[i].style.background = 'red';
	}
	odiv[index-1].style.display = 'block';
	odiv[index-1].style.background = 'blue';
}
</script>

</body>
</html>